{% extends "./base.html" %}

{% block title %}
    {% if tag %}
    标签页：{{ tag.name }}
    {% endif %}

    {% if category %}
    分类页：{{ category.name }}
    {% endif %}

{% endblock %}

{% block main %}
{% for post in post_list %}
<!--            <a href="/post/{{ post.id }}.html">{{ post.title }}</a>-->
<!--            <a href="{% url 'post-detail' post.id %}">{{ post.title }}</a>-->
<div class="card post">
    <div class="card-body">
        <h5 class="card-title"><a href="{% url 'post-detail' post.id %}">{{ post.title }}</a></h5>
        <span class="card-link">作者：<a href="#">{{ post.owner.username }}</a></span>
        <span class="card-link">
            分类：<a href="{% url 'category-list' post.category.id %}">{{ post.category.name }}</a>
        </span>
        <span class="card-link">标签：
            {% for tag in post.tag.all %}
            <a href="{% url 'tag-list' tag.id %}">{{ tag.name }}</a>
            {% endfor %}
        </span>
        <p class="card-text">{{ post.desc }}<a href="{% url 'post-detail' post.id %}">完整内容</a></p>
    </div>
</div>
{% endfor %}



        {% if page_obj %}

            {% if page_obj.has_previous %}
                <a href="?page={{ page_obj.previous_page_number }}">上一页</a>
            {% endif %}
            Page {{ page_obj.number }} of {{ paginator.num_pages }}
            {% if page_obj.has_next %}
                <a href="?page={{ page_obj.next_page_number }}">下一页</a>
            {% endif %}
        {% endif %}


{% endblock %}
